# @Time    :2025/4/6 23:28
class Stack(object):
    """栈"""

    def __init__(self):
        self._list = []

    def push(self, item):
        """添加一个新的元素item到栈顶"""
        self._list.append(item)

    def pop(self):
        """弹出栈顶元素"""
        return self._list.pop()

    def peek(self):
        """返回栈顶元素"""
        if self._list:
            return self._list[-1]
        else:
            return None

    def is_empty(self):
       if self._list:
           return False
       else:
           return True

    """ 判断栈是否为空"""

    def size(self):
        return len(self._list)

    """ 返回栈的元素个数"""


if __name__ == '__main__':
    s = Stack()#栈的特点：后进先出
    s.push(1)
    s.push(2)
    s.push(3)
    print(s.pop())
    print(s.pop())
